home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
aminet
/
util
/
gnu
/
gnu_tile_forth.lha
/
lib
/
blocks.f83
< prev
next >
Wrap
Text File
|
1992-05-19
|
2KB
|
77 lines
\
\ CODE BLOCK DEFINITIONS
\
\ Copyright (C) 1988-1990 by Mikael R.K. Patel
\
\ Computer Aided Design Laboratory (CADLAB)
\ Department of Computer and Information Science
\ Linkoping University
\ S-581 83 LINKOPING
\ SWEDEN
\
\ Email: mip@ida.liu.se
\
\ Started on: 30 June 1988
\
\ Last updated on: 28 June 1990
\
\ Dependencies:
\ (forth) forth, compiler
\
\ Description:
\ Code blocks as an alternative to passing functions as parameters.
\ Major usage for iterator function such as "map" and "?map".
\
\ Warning:
\ A code block should not contain the following words; "recurse",
\ "tail-recurse", "does>", and "exception>". These require an
\ entry binding to function correctly.
\
\ Copying:
\ This program is free software; you can redistribute it and\or modify
\ it under the terms of the GNU General Public License as published by
\ the Free Software Foundation; either version 1, or (at your option)
\ any later version.
\
\ This program is distributed in the hope that it will be useful,
\ but WITHOUT ANY WARRANTY; without even the implied warranty of
\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\ GNU General Public License for more details.
\
\ You should have received a copy of the GNU General Public License
\ along with this program; see the file COPYING. If not, write to
\ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
.( Loading Blocks definitions...) cr
vocabulary blocks ( -- )
compiler blocks definitions
4 cells field +block ( addr -- block) private
: block[ ( -- )
compiling ( Check interpreter state)
if here +block [compile] literal ( If compiling then create literal)
compile (branch) >mark ( to code section and branch over)
true ( Mark code compilation state)
else
here ( Return pointer to code section)
false ( Mark non-code compilation state)
] ( Start compiling code for block)
then
; immediate
: ]; ( -- block)
[compile] ; ( Compile what semicolon does)
if >resolve ( If within code resolve branch)
] ( And Continue compiling)
then
; immediate
: call ( block -- )
>r ( Perform the block definition)
;
forth only